﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class cn_common_menu_kfu : System.Web.UI.UserControl
{
    protected string Num = "";
    private string cid = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        cid = Request.QueryString["parentId"];
        if (!IsPostBack)
        {
            GetCategory();
        }
    }


    private void GetCategory()
    {
        //下级栏目
        string sqlStr = "select * from Whir_Column where parentID = 5  order by sort asc";
        DataTable dt = Whir.SQLServerDAL.DbHelperSQL.Query(sqlStr).Tables[0];
        if (dt != null && dt.Rows.Count > 0)
        {
            Num = dt.Rows.Count.ToString();
            rptList.DataSource = dt;
            rptList.DataBind();
        }

    }
    protected void rptList_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        Literal ltrNum = e.Item.FindControl("ltrNum") as Literal;
        Literal ltrCss=e.Item.FindControl("ltrCss") as Literal;
        Repeater rptCategory = e.Item.FindControl("rptCategory") as Repeater;
        DataRowView dr = e.Item.DataItem as DataRowView;
        string ColumnId = dr["ColumnId"].ToString();
        if (ltrNum != null)
        {
            if (string.IsNullOrEmpty(cid))
            {
                if (e.Item.ItemIndex == 0)
                {
                    ltrNum.Text = "2";
                    ltrCss.Text = "";
                }
                else
                {
                    ltrNum.Text = "1";
                    ltrCss.Text = "submenu";
                }
            }
            else
            {
                if (ColumnId == cid)
                {
                    ltrNum.Text = "2";
                    ltrCss.Text = "";
                }
                else
                {
                    ltrNum.Text = "1";
                    ltrCss.Text = "submenu";
                }
            }
        }

        string sqlStr = "select * from Whir_Column where parentID = " + ColumnId + "  order by sort asc";
        DataTable dt = Whir.SQLServerDAL.DbHelperSQL.Query(sqlStr).Tables[0];
        rptCategory.DataSource = dt;
        rptCategory.DataBind();
    }
}
